Completed
Pull Request — master (#81)
by Alejandro
03:28
created

provideServices.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 53
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 34
nc 1
nop 2
dl 0
loc 53
ccs 0
cts 27
cp 0
crap 2
rs 9.064
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A provideServices.js ➔ ... ➔ ??? 0 1 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
import { connect as reduxConnect } from 'react-redux';
2
import { assoc } from 'ramda';
3
import ShortUrls from '../ShortUrls';
4
import SearchBar from '../SearchBar';
5
import ShortUrlsList from '../ShortUrlsList';
6
import ShortUrlsRow from '../helpers/ShortUrlsRow';
7
import ShortUrlsRowMenu from '../helpers/ShortUrlsRowMenu';
8
import CreateShortUrl from '../CreateShortUrl';
9
import DeleteShortUrlModal from '../helpers/DeleteShortUrlModal';
10
import EditTagsModal from '../helpers/EditTagsModal';
11
import { listShortUrls } from '../reducers/shortUrlsList';
12
import { createShortUrl, resetCreateShortUrl } from '../reducers/shortUrlCreation';
13
import { deleteShortUrl, resetDeleteShortUrl, shortUrlDeleted } from '../reducers/shortUrlDeletion';
14
import { editShortUrlTags, resetShortUrlsTags, shortUrlTagsEdited } from '../reducers/shortUrlTags';
15 4
import { resetShortUrlParams } from '../reducers/shortUrlsListParams';
16
17
const provideServices = (bottle, connect) => {
18
  // Components
19
  bottle.serviceFactory('ShortUrls', ShortUrls, 'SearchBar', 'ShortUrlsList');
20
  bottle.decorator('ShortUrls', reduxConnect(
21
    (state) => assoc('shortUrlsList', state.shortUrlsList.shortUrls, state.shortUrlsList)
22
  ));
23
24
  bottle.serviceFactory('SearchBar', SearchBar, 'ColorGenerator');
25
  bottle.decorator('SearchBar', connect([ 'shortUrlsListParams' ], [ 'listShortUrls' ]));
26
27
  bottle.serviceFactory('ShortUrlsList', ShortUrlsList, 'ShortUrlsRow');
28
  bottle.decorator('ShortUrlsList', connect(
29
    [ 'selectedServer', 'shortUrlsListParams' ],
30
    [ 'listShortUrls', 'resetShortUrlParams' ]
31
  ));
32
33
  bottle.serviceFactory('ShortUrlsRow', ShortUrlsRow, 'ShortUrlsRowMenu', 'ColorGenerator');
34
35
  bottle.serviceFactory('ShortUrlsRowMenu', ShortUrlsRowMenu, 'DeleteShortUrlModal', 'EditTagsModal');
36
37
  bottle.serviceFactory('CreateShortUrl', CreateShortUrl, 'TagsSelector');
38
  bottle.decorator(
39
    'CreateShortUrl',
40
    connect([ 'shortUrlCreationResult' ], [ 'createShortUrl', 'resetCreateShortUrl' ])
41
  );
42
43
  bottle.serviceFactory('DeleteShortUrlModal', () => DeleteShortUrlModal);
44
  bottle.decorator('DeleteShortUrlModal', connect(
45
    [ 'shortUrlDeletion' ],
46
    [ 'deleteShortUrl', 'resetDeleteShortUrl', 'shortUrlDeleted' ]
47
  ));
48
49
  bottle.serviceFactory('EditTagsModal', EditTagsModal, 'TagsSelector');
50
  bottle.decorator('EditTagsModal', connect(
51
    [ 'shortUrlTags' ],
52
    [ 'editShortUrlTags', 'resetShortUrlsTags', 'shortUrlTagsEdited' ]
53
  ));
54
55
  // Actions
56
  bottle.serviceFactory('editShortUrlTags', editShortUrlTags, 'buildShlinkApiClient');
57
  bottle.serviceFactory('resetShortUrlsTags', () => resetShortUrlsTags);
58
  bottle.serviceFactory('shortUrlTagsEdited', () => shortUrlTagsEdited);
59
60
  bottle.serviceFactory('listShortUrls', listShortUrls, 'buildShlinkApiClient');
61
  bottle.serviceFactory('resetShortUrlParams', () => resetShortUrlParams);
62
63
  bottle.serviceFactory('createShortUrl', createShortUrl, 'buildShlinkApiClient');
64
  bottle.serviceFactory('resetCreateShortUrl', () => resetCreateShortUrl);
65
66
  bottle.serviceFactory('deleteShortUrl', deleteShortUrl, 'buildShlinkApiClient');
67
  bottle.serviceFactory('resetDeleteShortUrl', () => resetDeleteShortUrl);
68
  bottle.serviceFactory('shortUrlDeleted', () => shortUrlDeleted);
69
};
70
71
export default provideServices;
72